package com.zyd.shiro.mapper;


import com.zyd.shiro.entity.ArcFile;
import com.zyd.shiro.plugin.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


public interface ArcFileMapper extends BaseMapper<ArcFile> {

    @Select("<script> SELECT COUNT(*) FROM arc_file" +
            " WHERE `type`=0 "+
            "</script>")
    int countFile();

    @Select("<script> SELECT COUNT(*) FROM arc_file" +
            " WHERE `type`=1 " +
            "</script>")
    int countCase();

    @Select("<script> SELECT COUNT(*) FROM arc_file " +
            " WHERE including=1 " +
            "</script>")
    int countEle();


    @Select("<script> SELECT * FROM `arc_file` " +
            " WHERE " +
            " dire_id = #{direId}" +
            " AND type = 0"+
            "<if test='param !=null'>"+
            " AND "+
            " ( " +
            " archive_code LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " correct_title LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " recode_number LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " cert_number LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " male_gender LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " male_name LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " male_id_number LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " malebirth LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " male_orig_marital_status LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " male_addr_or_work LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " male_cert_type LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " male_id_type LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " male_nationality LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " male_nation LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " male_location LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " male_cert_number LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " female_gender LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " female_name LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " female_id_number LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " femalebirth LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " female_orig_marital_status LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " female_addr_or_work LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " female_cert_type LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " female_id_type LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " female_nationality LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " female_nation LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " female_location LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " female_cert_number LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " regist_authority LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " orig_regist_authority LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " regist_nature LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " orig_regist_date LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " under_agency LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " regist_name LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " del_not LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " marital_cert_remark LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " orig_marital_regist_date LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " orig_text LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " other_remark LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " indent LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " business_type LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " fond_number LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " files_number LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " box_number LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " subject_heading LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " storage_time LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " note LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " year LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " category_number LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " storage_address LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " doc_page LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " file_number LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " level_number LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%')  " +
            " ) "+
            "</if>"+
            "</script>")
    List<ArcFile> selectPageByDireId(@Param("direId") long direId,@Param("param") String param);


    @Select("<script> SELECT COUNT(*) FROM `arc_file` " +
            " WHERE " +
            " dire_id = #{direId}" +
            " AND type = 0"+
            "<if test='param !=null'>"+
            " AND "+
            " ( " +
            " archive_code LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " correct_title LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " recode_number LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " cert_number LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " male_gender LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " male_name LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " male_id_number LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " malebirth LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " male_orig_marital_status LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " male_addr_or_work LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " male_cert_type LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " male_id_type LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " male_nationality LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " male_nation LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " male_location LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " male_cert_number LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " female_gender LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " female_name LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " female_id_number LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " femalebirth LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " female_orig_marital_status LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " female_addr_or_work LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " female_cert_type LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " female_id_type LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " female_nationality LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " female_nation LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " female_location LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " female_cert_number LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " regist_authority LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " orig_regist_authority LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " regist_nature LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " orig_regist_date LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " under_agency LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " regist_name LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " del_not LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " marital_cert_remark LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " orig_marital_regist_date LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " orig_text LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " other_remark LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " indent LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " business_type LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " fond_number LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " files_number LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " box_number LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " subject_heading LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " storage_time LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " note LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " year LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " category_number LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " storage_address LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " doc_page LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " file_number LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%') or " +
            " level_number LIKE CONCAT('%',#{param , jdbcType=VARCHAR},'%')  " +
            " ) "+
            "</if>"+
            "</script>")
    long countByDireId(@Param("direId") long direId,@Param("param") String param);



    @Select("<script> SELECT * FROM arc_file "+
            " WHERE ${param}" +
            "</script>")
    List<ArcFile> fullSearch(@Param("param") String param);
}
